let fs = require('fs');
let request = require('request');
let path = require('path');
let url = require('url');
// 爬取抖音图片URL（复制到控制台执行，自行修改参数）
// const images = document.querySelectorAll(".V5BLJkWV");
// const sources = Array.from(images, (image) => image.src);
// console.log(sources);
// 把资源url赋值过来
const sources = [
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202208/b475dbf44f7de298514e909554dbb98e--3354033609.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202208/c1b46baaddbc5a759b6d60db28cf63e1--690368077.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202208/46e5ae04c3db4f1ae19d9be3c4dc9c0a--3083013582.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202208/5a6441bcc05bf7686729ea5e77d43f92--1836364273.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202208/b516ba536cdb02933dfc87bb1e92e6cf--2924140353.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202208/d53b6cc382a00b249c15ab6870e3f16d--3207484197.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/566a8102ff3e30b1b22a5556b20785a7--3018360363.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/452639cdeb57899a584277adc8fb7a68--2311511392.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/bec0e8985cf5614371df94d4ebab3ea4--1574013795.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/67d11b34556048eb2bef23dedeacbb14--2566723661.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/e75be8dece7d3a38f2b6684b688fbd71--3348953805.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/5e05b7c7e07a8.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/5dd4dc7682921.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/5d07531852baa.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/5d0752f3d3a24.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/5d0752874e4d0.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/89263c96d29df08d2d00e9e0af282334.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/2fe4ac8098a8b909edf647d86c9a77e7.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/d4e04150ae79e6eddb092bdf12a79f48.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/5d0752b2ef3cd.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/20d06eb1d7826dd9a4d57b3029203cb1.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/80ef1725af2ba5c77b7552cebd508df0.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/740e91b6fabdf210cf1a0e69319f63e3.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/f40f5daf53f1bbf5101bfc67e6e9d972.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/57e19213307dbf0a2268a3dea63c91df.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/f138c99705dd4fa1dc703f211eb9baa1.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/dd4146d659dfc8d91cf0995d8685ee47.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/73aa94467cf3e9cbdfc25480f1b4d1d4.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/8ada74c4babc6e48e760c4180dbe7246.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/9a7f678fc16223daa6f6a4cb14488cea.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/80066fc1cde2a9f60e079bd810dad57e.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/36c712f5f7bacdc2bd9429b479622038.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/8bc09ef61f90dea0b6173f4d6dcda71e.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/bff2847523168e243e275a1564104e5b.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/6abbfdb673da793df0065f58b6821235.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/8a4bfbd8f34025ec2be8ecf011d7dbd7.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/385ea45a8c1100ce7875881a466f81c0.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/f64d31a4977c3508f475a3b15fe6a482.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/dc613a66b18b6563135bebb1b06c6406.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/d9ed50892f01c93e9191bc50cb9b58d4.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/72048cfd4ee5a17c7b4ad2a39c4fa916.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/993cc68ba9d4069c2d135fc4c6ea99ac.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/5ad7098c98195a35a004bcf3a8e8f31a.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/650276e7be67aeac480e5c1dc7f08702.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/2649a524218d57adff9835972685d9b4.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/ec445bca3ea65b3f9adafabfd99fdf80.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/b2848171cc0ca11ee1bfe938f27918d0.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/7aa425d3df7b9036edf0fec0543c799f.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/32ca0015e8e8f54f76b78e386d5210b0.jpg",
    "http://cdn-hw-static2.shanhutech.cn/bizhi/staticwp/202209/d7919b53e5525573cb2961328bbce608.jpg"
]
let index = 74;
sources.forEach((e) => {
    let houzhui = path.extname(url.parse(e, true).pathname) == '.webp' ? '.jpg' : path.extname(url.parse(e, true).pathname)
    let filename = "1 (" + index + ")" + houzhui
    console.log(filename)
    index++;
    request(e).pipe(
        // 自行修改地址
        // fs.createWriteStream(`E://一些杂七杂八/一些nice的视频图片/抖音无水印/images/组图/${filename}`).on('close', err => { console.log('写入失败', err) })
        fs.createWriteStream(`../瀑布流懒加载/js方案/assets/${filename}`).on('close', err => { console.log('写入失败', err) })
    )
})